package com.slwu.exception;

import org.apache.commons.lang3.StringUtils;
import org.springframework.http.HttpStatus;

public class CommonException extends RuntimeException {
    private static final long serialVersionUID = -3608667856397125671L;

    public static final String MESSAGE = "未知错误，请联系系统管理人员！";

    private HttpStatus httpStatus;

    public CommonException() {
        super(MESSAGE);
        this.setHttpStatus(HttpStatus.INTERNAL_SERVER_ERROR);
    }

    public CommonException(String message) {
        super(StringUtils.isBlank(message) ? CommonException.MESSAGE : message);
        this.setHttpStatus(HttpStatus.INTERNAL_SERVER_ERROR);
    }

    public CommonException(String message, HttpStatus httpStatus){
        super(message);
        this.setHttpStatus(httpStatus);
    }

    public HttpStatus getHttpStatus() {
        return httpStatus;
    }

    public void setHttpStatus(HttpStatus httpStatus) {
        this.httpStatus = httpStatus;
    }
}
